// app/page.js
import { Suspense } from "react";
import { Spin } from "antd";
import HomePageClient from "@/components/home-client";
// 模拟数据获取函数
async function getData() {
  // console.log({ url: process.env.URL + "/api/avatar-list" });
  const result = await fetch(process.env.URL + "/api/avatar-list", { method: "GET" });
  if (result.ok) {
    return result.json();
  }
  return [];
}

// 使用 generateMetadata 函数动态生成元数据
export async function generateMetadata() {
  return {
    title: `首页`,
    description: "这是首页的描述",
  };
}

const HomePage = async () => {
  const res = await getData();

  return (
    <>
      <h1>首页1</h1>

      <Suspense fallback={<Spin tip="加载中..." />}>
        <HomePageClient initialData={res.data} />
      </Suspense>
    </>
  );
};

export default HomePage;
